package com.cjl.net.bio;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

public class BIOClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket();
        InetSocketAddress socketAddress = new InetSocketAddress("127.0.0.1",40000);
        System.out.println("Client.main");
            socket.connect(socketAddress);

            System.out.println("Client.main after connect "+socket.isConnected());

        try (ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());
             ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());) {
            outputStream.writeUTF("Mark");
            outputStream.flush();
            System.out.println("msg from Server:" + inputStream.readUTF());
        } finally {
            if (socket != null) {
                try {
                    socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }




    }
}
